package com.lm.controller;

import com.lm.pojo.ServicePackage;
import com.lm.pojo.TeamManage;
import com.lm.pojo.TeamRelation;
import com.lm.service.MyTeamDetailsService;
import com.lm.service.TeamManageService;
import com.lm.util.ResultUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "团队成员")
@RestController
@CrossOrigin("*")
@RequestMapping("/findteamdetails")
public class MyTeamDetailsController {

    @Autowired
    private MyTeamDetailsService myTeamDetailsService;

    @ApiOperation(value = "查询团队成员", httpMethod = "GET", notes = "根据团队ID查询团队列表")
    @GetMapping("/findTeamMember")
    public ResultUtil<List<TeamRelation>> findMyManagedTeams(@RequestParam("doctorTeamId") Integer doctorTeamId) {
        try {
            List<TeamRelation> members = myTeamDetailsService.findTeamMember(doctorTeamId);
            return new ResultUtil<>(200, "查询成功", members);
        } catch (Exception e) {
            e.printStackTrace();
            return new ResultUtil<>(500, "查询失败：" + e.getMessage());
        }
    }

    @ApiOperation(value = "查询团队服务包", httpMethod = "GET", notes = "根据团队ID查询团队列表")
    @GetMapping("/findTeamServicePackage")
    public ResultUtil<List<ServicePackage>> findTeamServicePackage(@RequestParam("doctorTeamId") Integer doctorTeamId) {
        try {
            List<ServicePackage> servicePackages = myTeamDetailsService.findTeamServicePackage(doctorTeamId);
            return new ResultUtil<>(200, "查询成功", servicePackages);
        } catch (Exception e) {
            e.printStackTrace();
            return new ResultUtil<>(500, "查询失败：" + e.getMessage());
        }
    }
}
